package thread;

import java.util.Scanner;

//  线程的等待    主线程等待子线程
public class demo10 {

    private static int sum = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (int i = 1; i <= 1000; i++) {
                sum += i;
            }
            System.out.println("t 线程结束");
        });

        t.start();

        // 等待 t 线程结束
        // main 线程等待 t 线程执行结束
        t.join();

        System.out.println(sum);

    }
}
